from django.conf.urls import url, include
from web.views import account, project, manages, dashboard, wiki

from django.views.static import serve
from django.conf import settings

urlpatterns = [
    # 图像接口开放
    url('media/(?P<path>.*)', serve, {'document_root': settings.MEDIA_ROOT}),
    # 短信发送
    url(r'^tencent/sms/', account.tencent_sms, name='tencent_sms'),
    # 注册功能
    url(r'^register.html/', account.register, name='register'),
    # 短信登录
    url(r'^login/sms.html/', account.login_sms, name='login_sms'),
    # 验证码登录
    url(r'^login/code.html/', account.login_code, name='login_code'),
    # 验证码图片
    url(r'^image/code/', account.image_code, name='image_code'),

    # 注销登录
    url(r'^login_out.html/', account.login_out, name='login_out'),
    # 项目路由
    url(r'^project.html/', project.project_list, name='project'),
    # 添加星标
    url(r'^add/star/(?P<project_type>\w+)/(?P<project_id>\d+)', project.add_star, name='add_star'),
    # 取消星标
    url(r'^un/star/(?P<project_type>\w+)/(?P<project_id>\d+)', project.un_star, name='un_star'),
    # 项目列表
    # 坑1 未添加反斜杠，.....导致路由重叠 href="/manage/1dashboard.html/
    url(r'^manage/(?P<project_id>\d+)/', include([
        url(r'^wiki.html/', wiki.wiki, name='wiki'),
        url(r'^wiki/add.html/', wiki.wiki_add, name='wiki_add'),
        url(r'^wiki/delete.html/', wiki.wiki_delete, name='wiki_delete'),
        url(r'^wiki/edit.html/(?P<wiki_id>\d+)/', wiki.wiki_edit, name='wiki_edit'),
        url(r'^wiki/upload/img.html/', wiki.upload_img, name='upload_img'),
        url(r'^wiki/multilevel/directory/', wiki.multilevel_directory, name='multilevel_directory'),

        url(r'^file.html/', manages.file, name='file'),
        url(r'^issues.html/', manages.issues, name='issues'),
        url(r'^dashboard.html/', dashboard.dashboard, name='dashboard'),
        url(r'^statistics.html/', manages.statistics, name='statistics'),
        url(r'^settings.html/', manages.settings, name='settings'),
    ], None, None)),
    # home
    url(r'', account.home, name='home'),
]
